import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {timer} from 'rxjs';

@Component({
  selector: 'app-router-mode',
  templateUrl: './router-mode.component.html',
  styleUrls: ['./router-mode.component.css']
})
export class RouterModeComponent implements OnInit {
  routerInfo: string;
  routerValue: string;
  returnValue: string;
  routers = [
    {name: '全局', value: '0'},
    {name: '绕过局域网地址', value: '1'},
    {name: '绕过大陆地址', value: '2'},
    {name: '绕过局域网及大陆地址', value: '3'},
  ];
  @Output() success = new EventEmitter();
  constructor() { }

  ngOnInit() {
    for (const item of this.routers) {
      if (this.routerValue === item.value) {
        this.routerInfo = item.name;
      }
    }
  }

  changeRouter(value: string) {
    this.routerValue = value;
  }

  closeModel() {
    timer(200).subscribe(() => {
      this.success.emit(this.routerValue);
    });
  }
}
